<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>验证码比较</title>
  <link rel="stylesheet" href="css/login_reg.css" type="text/css">
  <script src="js/jquery-3.3.1.js"></script>
  <script >
    $(function (){
      $.post(
              //uri
              "/music/user/findEmail",
              //参数
              {},
              //回调函数
              function (info){
                var email = info.data;
                $("#email").html(email);
              },"json");
      $("#sub").click(function (){
        //2.使用ajax发送请求 - 验证单击事件
        $.post(
                //uri
                "/music/user/compareCode",
                //参数
                $("#compareForm").serialize(),
                //回调函数
                function (info){
                  if (info.flag){
                    //验证码匹配,跳转到新密码
                    location.href = "newpassword.html";
                  }else {
                    //匹配失败
                    $("#errorMsg").html(info.errorMsg);
                  }
                },"json");})

    });

  </script>
</head>
<body class="login-bg">

<div class="login">
  <div class="message">忘记密码
  </div>
  <div id="darkbannerwrap"></div>
  <form id="compareForm" action="" method="post" >
    已发送验证码到<span id="email"></span>邮箱,请进行查看
    <input name="code"   type="text" placeholder="请输入验证码" >
    <hr class="hr15">
    <input type="button" id="sub" value="验证">
    <hr class="hr20" >
    <div id="errorMsg" style="margin: 0 auto ; text-align: center"></div>
  </form>

</div>